//
//  FuJinTableViewCell.m
//  GOGOTravel
//
//  Created by dllo on 16/3/3.
//  Copyright © 2016年 果果. All rights reserved.
//

#import "FuJinTableViewCell.h"
#import "FuJin.h"
@implementation FuJinTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubViews];
    }
    return self;
}

- (void)createSubViews{
    
    self.imageView1 = [[UIImageView alloc] init];
    [self.contentView addSubview:_imageView1];
    [_imageView1 release];
    
    self.titleLabel = [[BaseLabel alloc] init];
    [self.contentView addSubview:_titleLabel];
    [_titleLabel release];
    
    self.JuLiLabel = [[BaseLabel alloc] init];
    [self.contentView addSubview:_JuLiLabel];
    [_JuLiLabel release];
    
    self.comLabel = [[BaseLabel alloc] init];
    [self.contentView addSubview:_comLabel];
    [_comLabel release];
    
    self.QuGuoLabel = [[BaseLabel alloc] init];
    [self.contentView addSubview:_QuGuoLabel];
    [_QuGuoLabel release];
    
    self.labelText = [[BaseLabel alloc] init];
    [self.contentView addSubview:_labelText];
    [_labelText release];
    
    
    self.ZanWuLabel = [[BaseLabel alloc] init];
    [self.contentView addSubview:_ZanWuLabel];
    _ZanWuLabel.alpha = 0;
    [_ZanWuLabel release];
}


- (void)setModel:(FuJin *)model{
    if (_model != model) {
        [_model release];
        _model = [model retain];
    }
    
    
    
   [_imageView1 sd_setImageWithURL:[NSURL URLWithString:_model.cover_route_map_cover] placeholderImage:[UIImage imageNamed:PLACE_HLODER]];
        
    

    _titleLabel.text = _model.name;
    
    NSString *strM = [_model.rating_users stringValue];
    if ([strM isEqualToString:@""]) {
        _comLabel.text = @"暂无点评";
        
    }else{
        _comLabel.text = [NSString stringWithFormat:@"%@ 点评", strM];
    }
    
    
    if (_model.tips.count > 0) {
        NSDictionary *dic = _model.tips[0];
        
        _labelText.text = dic[@"content"];
    }else{
        _labelText.text = @"暂无评论";
    }
    
    
    
    _JuLiLabel.text = [NSString stringWithFormat:@"距我%d m", 545];
    
    _QuGuoLabel.text = [NSString stringWithFormat:@"%@ 人去过", _model.visited_count];
    
}

- (void)layoutSubviews{
    
    _imageView1.frame = CGRectMake(5, 5, 120, 90);
    _imageView1.layer.cornerRadius = 5;
    _imageView1.layer.masksToBounds = YES;
    _imageView1.backgroundColor = [UIColor whiteColor];
    
    
    _titleLabel.frame = CGRectMake(140, 5, 200, 30);
    
    _comLabel.frame = CGRectMake(255, 30, 50, 20);
    _comLabel.font = [UIFont systemFontOfSize:11];
    
    
    _labelText.frame = CGRectMake(140, 40, [UIScreen mainScreen].bounds.size.width - 140 - 20, 40);
    _labelText.numberOfLines = 2;
    _labelText.font = [UIFont systemFontOfSize:11];
    _labelText.backgroundColor = [UIColor clearColor];
    
    _JuLiLabel.frame = CGRectMake(140, 77, 60, 20);
    _JuLiLabel.font = [UIFont systemFontOfSize:11];
    
    
    _QuGuoLabel.frame = CGRectMake(240, 77, 60, 20);
    _QuGuoLabel.font = [UIFont systemFontOfSize:11];
    
    _ZanWuLabel.frame =  CGRectMake(0, 0, 50, 30);
    _ZanWuLabel.center = _imageView1.center;
    _ZanWuLabel.font = [UIFont systemFontOfSize:12];
}






- (void)dealloc{
    
    [_imageView1 release];
    [_titleLabel release];
    [_QuGuoLabel release];
    [_comLabel release];
    [_labelText release];
    [_JuLiLabel release];
    
    [super dealloc];
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
